package com.oracle.application.controller;




import com.oracle.application.entity.PagePo;
import com.oracle.application.entity.Product;
import com.oracle.application.feign.ProductFeign;

import com.oracle.application.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.ServletRequest;

@RestController
@RequestMapping("")
public class ProductController {
    @Autowired
    private ProductFeign productFeign;
    @RequestMapping("/Product/getAllProduct")
    public R<PagePo> getAllProduct(@RequestParam(value = "psgeIndex",defaultValue = "1")Integer pageIndex, @RequestParam(value = "pageCount",defaultValue = "10")Integer pageCount){
        return productFeign.getAllProduct(pageIndex,pageCount);
    }
    @RequestMapping("/Product/getProductById")
    public R<Product> getProductById(@RequestParam("id") Integer id ){
        return productFeign.getProductById(id);
    }
    @RequestMapping("/Product/insetProduct")
    public R insetProduct(@RequestBody Product product, @RequestParam("typeid") Integer typeid){
        return productFeign.insetProduct(product,typeid);
    }
    @RequestMapping("/Product/removeProduct")
    public R removeProduct(@RequestParam("id") Integer id){
        return productFeign.removeProduct(id);
    }
    @RequestMapping("/Product/updateProduct")
    public R updateProduct(@RequestBody Product product,@RequestParam("typeid") Integer typeid){
        return productFeign.updateProduct(product,typeid);
    }

}
